<?php 

    $exibeGrade = (sizeof($gradeList->getResult()) > 0) ? 'block' : 'none';
    
?>
<div align="left" id="div_grade_interna" style="display: <?= $exibeGrade; ?>">
<fieldset style="width:auto; background-color: #FFFFFF">
                    <legend style="size:auto; font-weight:bold; color:#333333">Grade Hor&aacute;ria</legend>
                    <table id="listaGrade">
                        <tr style="background-color: #cccccc; color:#FFFFFF ">
                          <td width="124"><div align="center">Disciplina</div></td>
                          <td width="192"><div align="center">Professor</div></td>
                          <td width="51"><div align="center">1&ordm; Bim</div></td>
                          <td width="50"><div align="center">2&ordm; Bim</div></td>
                          <td width="50"><div align="center">3&ordm; Bim</div></td>
                          <td width="50"><div align="center">4&ordm; Bim</div></td>
                          <td width="10"><div align="center">&nbsp;</div></td>
                      </tr>
    
<?php 
    foreach ($gradeList->getResult() as $grade) {
        
        $disciplina = $this->em->find('models\disciplina',$grade->getDisciplinaCod());
        $professor = $this->em->find('models\funcionario',$grade->getProfessorCod());

 ?>
         
         <tr id="tr_<?= @$grade->getGradeId() ?>">
             <td width="124"><div align="center"><?= utf8_encode(@$disciplina->getDisciplinaDesc()) ?></div></td>
             <td width="192"><div align="center"><?= utf8_encode(@$professor->getNomeFunc()) ?></div></td>
             <td width="51"><div align="center"><?= @$grade->getPrimeiroBim() ?></div></td>
             <td width="50"><div align="center"><?= @$grade->getSegundoBim() ?></div></td>
             <td width="50"><div align="center"><?= @$grade->getTerceiroBim() ?></div></td>
             <td width="50"><div align="center"><?= @$grade->getQuartoBim() ?></div></td>
             <td width="10">
                 <div align="center">
                     <a href="#" id="btnDetalDisciplinaGrade"  onclick="detalhaDisciplinaGrade(<?= @$grade->getGradeId() ?>)">
                        	<img src="<?php echo base_url() . 'assets/images/ico_view.png' ?>" />
                        </a>
                 </div>
             </td>
                
   
          </tr>
 <?php        
         
        
    }
 ?>
        </table>    
</fieldset>
</div>
<script>
    function detalhaDisciplinaGrade(gradeId){
        
        jQuery.ajax( {
                type: "POST",
                url: '?c=c_grade_horaria&m=detalhaDisciplinaGrade',
                cache: false,
                data: {gradeId:gradeId},
                beforeSend: function (){
                    $('#div_body').addClass("div_carregando");
                },
                complete:  function(){
                    $('#div_body').removeClass("div_carregando");

                },
                success: function(data){
                   
                    jQuery.facebox(data);
                }
            });
        
    }
</script>